home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 1936 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.7 KB  |  91 lines

  1. Path: nntp.teleport.com!sschaem
  2. From: sschaem@teleport.com (Stephan Schaem)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: PPC compilers
  5. Date: 25 Jan 1996 11:47:23 GMT
  6. Organization: Teleport - Portland's Public Access (503) 220-1016
  7. Distribution: world
  8. Message-ID: <4e7qkb$4fo@maureen.teleport.com>
  9. References: <4d42gg$i2p@ra.ibr.cs.tu-bs.de> <4dov8s$rc5@ar.ar.com.au> <38232132@kone.fipnet.fi>
  10. NNTP-Posting-Host: kelly.teleport.com
  11. X-Newsreader: TIN [version 1.2 PL2]
  12.  
  13. Jyrki Saarinen (jsaarinen@kone.fipnet.fi) wrote:
  14.  
  15. : > To do fast 16:16 bit fixed point maths (ie for bitmap scaling). You have
  16. : > the fraction in the  high word and the integer part in the low word. 
  17. : >áBecause of the addx, every time the fraction wraps around, the X bit is set 
  18. : >áand next add, the integer bit is incremented.
  19.  
  20. : Addx is really great .. Hmm. We could think of all the
  21. : situations where addx could possibly go wrong. (I mean
  22. : fixed point interpolations)
  23.  
  24. : At least this has to be done before the loop:
  25. :         moveq   #0,d0
  26. :         add.l   d1,d0
  27.  
  28.  I dont see what this do... clear x? sub.l d0,d0
  29.  
  30. :         ...
  31. : .loop   addx.l  d1,d2
  32. :         dbf     d7,.loop
  33.  
  34. : But what about if there is two addx? Theis decimal parts
  35. : have to be switched, which is done nicely with eor
  36. : before swapping, but what about that before loop
  37. : correction? Of course this perfect accuracy
  38. : is not required on 16.16 fixed point but if
  39. : there is a smaller amount of fraction, the
  40. : errors can be quite big..
  41.  
  42.  you actually to 3 add per inst:
  43.  
  44. 1) addx.l    d2,d0
  45. 2) addx.l    d3,d1
  46.  
  47.  = 
  48.  
  49. 1)    aa'[iteration] += aa"[iteration] + aoverflow of (ab' + ab")
  50.     boverflow = bb' + bb"[iteration]
  51. 2)    bb'[iteration] += bb"[iteration] + boverflow of (bb' + bb")
  52.     aoverflow = ab' + ab"[iteration+1]
  53.  
  54.  So, to enter and leave the loop corectly:
  55.  
  56. a) have a loop count of loopcount -1
  57. b) what you need to do is ab' + ab" before you enter the loop... 
  58. c) addx.w d3,d1 after the dbra so you dont do the ab' + ab" operation
  59.  
  60.  So:
  61. {
  62.     aoverflow = ab' + ab"[iteration]
  63. LOOP-1:
  64. 1)    aa'[iteration] += aa"[iteration] + aoverflow of (ab' + ab")
  65.     boverflow = bb' + bb"
  66. 2)    bb'[iteration] += bb"[iteration] + boverflow of (bb' + bb")
  67.     aoverflow = ab' + ab"[iteration+1]
  68. ENDLOOP:
  69. 1)    aa'[iteration] += aa"[iteration] + aoverflow of (ab' + ab")
  70.     boverflow = bb' + bb"
  71. 2)    bb'[iteration] += bb"[iteration] + boverflow of (bb' + bb")
  72. }
  73.  
  74.  that translate too:
  75.     
  76.     ...
  77.     move.l    d3,d4
  78.     sub.w    d4,d4
  79.     add.l    d0,d1        ; only add decimal part
  80. .Loop    addx.l    d2,d0
  81.     addx.l    d3,d1
  82.     dbra    d7,.Loop
  83.     addx.l    d2,d0
  84.     addx.w    d3,d1        ; only add integer part
  85.     ...
  86.  
  87.  if you only use 8bit integer, you can have 24bit for the decimal point.
  88.  basicly the case when steping 256xY(max256) texture map array.
  89.  
  90.  Stephan
  91.